﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace EMall.IdentityService.Menus
{
    public class MenuEntityTypeConfiguration : IEntityTypeConfiguration<Menu>
    {
        public void Configure(EntityTypeBuilder<Menu> builder)
        {
            builder.ToTable("Menus");
            builder.Ignore(p => p.DomainEvents);
            builder.HasKey(p => p.Id);
            builder.Property(p => p.Name).IsRequired();
            builder.Property(p => p.Code).IsRequired();
            builder.Property(p => p.Type).IsRequired();
            builder.Property(p => p.Route);
            builder.Property(p => p.Path);
            builder.Property(p => p.Extensions);
            builder.Property(p => p.ParentId).IsRequired().HasDefaultValue(0);
        }
    }
}
